import {get, post, put} from "@/utils/request";
import {AxiosPromise, Option} from "@/types/common";

/**
 * 根据 ID 获取工程信息
 * @param id 工程 ID
 */
export const useProjectApi = (id: number) => {
	return get('/generator/v1/project/' + id)
}

/**
 * 新增或更新工程信息
 * @param dataForm 表单信息
 */
export const useProjectSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return put('/generator/v1/project', dataForm)
	} else {
		return post('/generator/v1/project', dataForm)
	}
}

/**
 * 工程选项列表
 */
export const useProjectOptionListApi = (): AxiosPromise<Option[]> => {
	return get('/generator/v1/project/options')
}

